package com.peki.Controller;


import com.peki.Model.Products;
import com.peki.Service.ProductService;
import com.peki.base.BaseResponse;
import com.peki.base.PageResp;
import com.peki.base.SearchHttp;
import com.peki.base.http;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * Classname: ProductController
 * Package: com.bimowu.first.controller
 * Description:
 *
 * @Author 是佩奇呀
 * @Create 2024/1/18 9:59
 * @Version 1.8
 */
@RestController
@RequestMapping(value = "/product")
public class ProductController {

    @RequestMapping("/add")//增加
    public BaseResponse add (@Valid @RequestBody http req) throws Exception {
        return productService.add(req);
    }


    @RequestMapping("/delete")//删除
    public BaseResponse delete(@Valid @RequestBody http req) throws Exception {
        return productService.delete(req);
    };


    @RequestMapping("/update")//修改
    public BaseResponse update(@Valid @RequestBody http req) throws Exception {
        return productService.update(req);

    }

    @RequestMapping(value = "/list")//查询
    public BaseResponse<PageResp<Products>> list(@Valid @RequestBody SearchHttp req) throws Exception {
                return BaseResponse.OK(productService.list(req));

    }


}
